package com.aliyun.messagemgt.repository;

import com.aliyun.messagemgt.converter.BaseMessageTemplateParamConverter;
import com.aliyun.messagemgt.dto.BaseMessageTemplateParamDTO;
import com.aliyun.messagemgt.entities.BaseMessageTemplateParam;
import com.aliyun.messagemgt.repository.mappers.BaseMessageTemplateParamMapper;
import com.aliyun.messagemgt.domain.repository.IBaseMessageTemplateParamService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 基础表-消息模板参数表 服务实现类
 * </p>
 *
 * @author wugongzi
 * @since 2021-09-15
 */
@Service
public class BaseMessageTemplateParamServiceImpl implements IBaseMessageTemplateParamService {

    @Autowired
    private BaseMessageTemplateParamMapper baseMessageTemplateParamMapper;

    @Override
    public List<BaseMessageTemplateParamDTO> selectByTemplateId(Long TemplateId) {
        QueryWrapper<BaseMessageTemplateParam> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("template_id",TemplateId);
        queryWrapper.eq("is_deleted", "N");
        List<BaseMessageTemplateParam> baseMessageTemplateParamList = baseMessageTemplateParamMapper.selectList(queryWrapper);
        List<BaseMessageTemplateParamDTO> baseMessageTemplateParamDTOList = BaseMessageTemplateParamConverter.INSTANCE.baseMessageTemplateParamList2baseMessageTemplateParamDTOList(baseMessageTemplateParamList);
        return baseMessageTemplateParamDTOList;
    }
}
